/*
 *GreyBox was written by Strategic Data Systems and licenced under the open source MS-PL. 
 */
using System;
using System.Configuration;
using System.Diagnostics;

namespace StrategicDataSystems.Cloud.Monitoring.Configuration
{
    public class Settings
    {
        const int DefaultRefreshTimerIntervalInMinutes = 15;
        private int _refreshTimerIntervalInMinutes;

        public Settings()
        {
            SubscriptionId = ConfigurationManager.AppSettings["SubscriptionId"];
            CertificateThumbprint = ConfigurationManager.AppSettings["CertificateThumbprint"];
            
            if (!Int32.TryParse(ConfigurationManager.AppSettings["RefreshTimerIntervalInMinutes"], out _refreshTimerIntervalInMinutes))
            {
                _refreshTimerIntervalInMinutes = DefaultRefreshTimerIntervalInMinutes;
                Trace.WriteLine("The value in the configuration settings for RefreshTimerIntervalInMinutes is not a valid Integer (int) value.  Using default value.");
            }
            Trace.WriteLine(String.Format(
                                "Setting read. SubscriptionId: {0}, Thumbprint: {1}, TimerInternal: {2} Minutes",
                                SubscriptionId,
                                CertificateThumbprint,
                                _refreshTimerIntervalInMinutes.ToString()));
        }

        public string SubscriptionId { get; private set; }

        public string CertificateThumbprint { get; private set; }

        public int RefreshTimerIntervalInMinutes
        {
            get
            {
                return _refreshTimerIntervalInMinutes;
            }
        }
    }
}
